	<div class="row">
		<div class="col-sm-offset-2 col-sm-8 mainbar">
	<div class="detail">
	    <h2>绑定手机号</h2>
	    <p>绑定手机号后，您可以通过手机号登录网站，手机短信重置登录密码，接受重要消息通知等。</p>
	    <hr/>
	    <p>输入您的手机号，输入图片验证码，点击获取手机短信</p>
	    <p>输入手机收到的短信验证码，点击绑定即可</p>
	    <hr/>
	    <?php echo $this->Form->create('User', array(
			'url' => array('controller' => 'users', 'action' => 'bindMobile'),
			'class'=>'form-horizontal'
		) );?>
			
				{{$this->Session->flash()}}
				
	        <fieldset>
	        <div class="form-group clearfix">
                        <label class="col-sm-3 control-label" for="register-mobile">手机号</label>
                        <div class="col-sm-8">
                          <input type="text"  required="required" placeholder="输入您的手机号" name="data[User][mobile]"  id="register-mobile" maxlength="32"  class="form-control">
                          <div style="margin-top:5px;">
                          	<input style="display:inline-block;width:80px;" type="text" placeholder="验证码" class="form-control" minlength="4" maxlength="4" id="sms-captcha">
                        	<a href="javascript:void(0)" title="看不清，点击换一张" onclick="change_captcha();"><img style="height:38px;" id="register-captcha" src="{{$this->Html->url('/users/captcha')}}"/></a>
                        	<input type="button" class="btn btn-default" id="btn-send-msg" value="发送短信验证码" onclick="send_msg();">
                          </div>
                        </div>
                  </div>
                  
				<div class="form-group clearfix">
                        <label class="col-sm-3 control-label" for="register-mobile">短信验证码</label>
                        <div class="col-sm-8">
                          <input type="number"  required="required" placeholder="输入手机接收短信中的4位验证码" name="data[User][captcha]"  id="register-mobile" maxlength="4"  class="form-control">
                        </div>
                  </div>
	        
		     <div class="form-group">
						<label class="col-sm-3 txt-left"></label>
						<div class="col-sm-8"><input class="btn btn-primary" type="submit" value="{{__('绑定手机号')}}"></div>
			</div>
	        </fieldset>
	    </form>
	</div>
		</div>
	</div>
<script>
function change_captcha(){
	$('#register-captcha').attr('src','{{$this->Html->url('/users/captcha')}}?_='+randomString(8));
}
function send_msg(){
	var mobile = $('#register-mobile').val();
	var captcha = $('#sms-captcha').val();
	if(mobile == '') {
		showErrorMessage("请输入手机号");return false;
	}
	else if(captcha == '') {
		showErrorMessage("请输入图片验证码后再获取短信");return false;
	}
	ajaxAction('/users/send_msg/0', {mobile:mobile,captcha:captcha},null,function(request){
		if(request.ret == 0){
			showSuccessMessage(request.msg);
			var time = 90;
			var send_msg_ti = setInterval(function(){				
				if(time > 0) {
					$('#btn-send-msg').attr('disabled','distabled');
					$('#btn-send-msg').val('再次发送('+time+'秒后)');
				}
				else{
					$('#btn-send-msg').removeAttr('disabled');
					$('#btn-send-msg').val('发送短信验证码');
					clearInterval(send_msg_ti);
				}
				time--;
			},1000);
		}
		else{
			showErrorMessage(request.msg);
			change_captcha();
		}
	});
}

</script>